<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>仓库管理</title>
		<link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css"  tppabs="https://www.layui.site/layui/dist/css/layui.css"  media="all">
	</head>
	<body>
		<script type="text/html" id="toolbarDemo">
		  <div class="layui-btn-container">
		    <button class="layui-btn layui-btn-sm" id="warehouseInsert" lay-event="warehouseInsert">新&nbsp;&nbsp;&nbsp;增</button>
			<button class="layui-btn layui-btn-sm layui-btn-normal" id="warehouseUpdate" lay-event="warehouseUpdate">修&nbsp;&nbsp;&nbsp;改</button>
			<button class="layui-btn layui-btn-sm layui-btn-danger" id="warehouseDelete" lay-event="warehouseDelete">删&nbsp;&nbsp;&nbsp;除</button>
		  </div>
		</script>
		
		<div style="margin: 15px;">
			<table class="layui-hide" lay-data="{id: 'custId'}" lay-filter="member" id="test3"></table>
		</div>
		<script src="../../layui/layui.js" charset="utf-8"></script>
		<script>
			layui.use(['form', 'table', 'layer'], function(){
				var tree = layui.tree
				    ,layer = layui.layer
					,table = layui.table
					,$ = layui.jquery;
					
				table.on('toolbar(member)', function(obj){
					switch(obj.event){
					  case 'warehouseInsert':
						layer.open({
							type: 2,
							title: '仓库添加',
							scrollbar: false,
							area: ['700px', '90%'],
							content: 'warehouseInsert.html?flag=inset'
						});
					  break;
					  case 'warehouseUpdate':
						layer.open({
							type: 2,
							title: '仓库的修改说',
							scrollbar: false,
							area: ['700px', '90%'],
							content: 'warehouseInsert.html?flag=update'
						});
					  break;
					  case 'warehouseDelete':
						layer.confirm('真的删除行么', function(obj){
							var checkStatus = table.checkStatus('custId');
							var data = checkStatus.data
							console.log(data[0].custId) //获取选中行的数据
							$.get("/updateMemberInfoDelect",{custId:data[0].custId},function(row){
								if(row = 1){
									layer.msg("删除成功")
								}else{
									layer.msg("删除失败")
								}
							})
						  //向服务端发送删除指令
						});
					  break;
					};
				})
				
				table.render({
				    elem: '#test3'
				    ,url: '../../api/aaa.json'
					,id: 'custId'
					,toolbar: '#toolbarDemo'
				    ,cols: [[
						{type:'depotId',title: '仓库编号',hide:true}
				      ,{field:'depotName', width:100, title: '仓库名称'}
				      ,{field:'empId', width:120, title: '员工编号(负责人)'}
				      ,{field:'depotPhone', width:120, title: '联系电话'}
				      ,{field:'depotAdress', width:120, title: '仓库地址'}
				      ,{field:'depotState', width: 150 , title: '仓库状态'}
				      ,{field:'depotDefault', width:120, title: '默认仓库状态'}
				      ,{field:'depotComment', width:120, title: '备注'}
				    ]],
				    limits: [10, 15, 20, 25, 50, 100],
				    page: true
				});
			})
		</script>
	</body>
</html>